- name: check/create instance
  hosts: 209.132.184.147
  user: root
  gather_facts: False

  vars_files: 
   - /srv/web/infra/ansible/vars/global.yml
   - ${private}/vars.yml

  tasks:
  - include: $tasks/persistent_cloud.yml
  - include: $tasks/growroot_cloud.yml

- name: provision instance
  hosts: 209.132.184.147
  user: root
  gather_facts: True
  vars:
   - tcp_ports: [22, 80, 443]
   - udp_ports: []

  vars_files: 
   - /srv/web/infra/ansible/vars/global.yml
   - ${private}/vars.yml
   - ${vars}/${ansible_distribution}.yml

  tasks:
  - include: $tasks/cloud_setup_basic.yml
  - include: $tasks/postfix_basic.yml

  # packages needed
  - name: add packages for repo
    action: yum state=present name=$item
    with_items:
    - euca2ools
    - rsync
    - openssh-clients
    - system-config-firewall-base

  - name: install dependencies of fedocal
    action: yum state=installed pkg=$item
    with_items:
    - mod_wsgi
    - mod_ssl
    - python-flask
    - python-flask-wtf
    - mysql-server
    - MySQL-python
    - python-sqlalchemy
    - python-kitchen
    - python-fedora
    - python-vobject
    - pytz
    - python-alembic
    - python-fedora-flask
    tags:
    - packages

  - name: mount up disk of fedocal persistent storage
    action: mount name=/srv/persist src='LABEL=fedocal.dev' fstype=ext4 state=mounted

  # open up tcp ports 
  - name: poke holes in the firewall
    action: command lokkit -p '${item}:tcp'
    with_items: $tcp_ports


  handlers:
  - include: $handlers/restart_services.yml
